﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SW_SoftBully.Models;
using System.Json;
using log4net;
using SW_SoftBully.Models.ModuloAdministracion.Gasto;
using SW_SoftBully.Controllers.ModuloAdministracion;

namespace SW_SoftBully.Controllers.ModuloAdministracion.Gasto
{
    public class GastoController : Controller
    {
        //
        // GET: /Gasto/

        private SoftBullyDB db = new SoftBullyDB();
        GastoFacade gastoFacade = new GastoFacade();

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Gasto() 
        {
            return View();
        }

        public ActionResult RegistrarGasto()
        {
            return View();
        }

        public ActionResult BuscarGasto()
        {
            return View();
        }

        [HttpPost]
        public JsonResult registrarEdificio(GastoBean gasto)
        {

            //System.Diagnostics.Debug.WriteLine("--------------------------------------> " + departamento.ID);

            //return Json(new { me = proveedor.RUC });

            if (gastoFacade.Existegasto(gasto))
            {
                return Json(new { me = "El proveedor ya existe" });
            }

            string conexion = gastoFacade.Registrargasto(gasto);

            if (conexion == "Bien")
            {
                return Json(new { me = "Se ingreso correctamente" });
                //Console.WriteLine("Hola");
            }
            else
            {
                return Json(new { me = "Existe un error" });
                //Console.WriteLine("Hola");
            }
        }

        [HttpPost]
        public JsonResult buscarProveedor(GastoBean gasto)
        {
            List<GastoBean> listaProveedor = gastoFacade.Listargasto(gasto);
            return Json(new { listaProveedor });
        }

    }
}
